package com.tmt.im.common.pojo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tmt.im.common.annotation._AllowUpdate;
import com.tmt.springboot.common.annotation._JsonBinding;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.apache.ignite.cache.query.annotations.QuerySqlField;

import java.io.Serial;
import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * 提现历史记录表
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/6 21:11
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class WithdrawHistoryPoJo implements IGetKey<Long> {

    public static final String CACHE_NAME = "withdraw_history";

    @Serial
    private static final long serialVersionUID = -3616224132513932907L;

    @QuerySqlField(name = "id", index = true)
    private Long id;

    /**
     * 收款的商户号
     */
    @QuerySqlField(name = "merchant_num")
    @_JsonBinding("merchantNum")
    private String merchantNum;

    /**
     * 商户订单号: 仅允许字母或数字类型,建议不超过32个字符，不要有中文
     */
    @QuerySqlField(name = "order_no")
    @_JsonBinding("orderNo")
    private String orderNo;

    /**
     * 提现金额：请求的价格(单位：分)
     */
    @QuerySqlField(name = "withdraw_amount")
    @_JsonBinding("withdrawAmount")
    private Long withdrawAmount;

    /**
     * 提现手手续费。
     */
    @QuerySqlField(name = "withdraw_fee")
    private Long withdrawFee;

    /**
     * 异步通知地址
     * 异步接收支付结果通知的回调地址，通知url必须为外网可访问的url，不能携带参数。
     */
    @QuerySqlField(name = "notify_url")
    @_JsonBinding("notifyUrl")
    private String notifyUrl;

    /**
     * 提现方式：wechat, bankCard, alipay, szrmb
     */
    @QuerySqlField(name = "channel_code")
    @_JsonBinding("channelCode")
    private String channelCode;

    /**
     * 接收账号，不同的提现方式对应不同的账号（支付宝账号或银行卡号）
     */
    @QuerySqlField(name = "bank_card_account")
    @_JsonBinding("bankCardAccount")
    private String bankCardAccount;

    /**
     * 提现到银行卡时，必须提交开户行信息。
     */
    @QuerySqlField(name = "open_account_bank")
    @_JsonBinding("openAccountBank")
    private String openAccountBank;

    /**
     * 收款人对应不同系统中的昵称。
     */
    @QuerySqlField(name = "account_holder")
    @_JsonBinding("accountHolder")
    private String accountHolder;

    /**
     * 商户端用户ID
     */
    @QuerySqlField(name = "user_id")
    @_JsonBinding("userId")
    private String userId;

    /**
     * 商户端的用户昵称
     */
    @QuerySqlField(name = "user_nick")
    @_JsonBinding("userNick")
    private String userNick;

    /**
     * 签名【md5(商户号+商户订单号+支付金额+异步通知地址+商户秘钥)】
     */
    @QuerySqlField(name = "sign")
    @_JsonBinding("sign")
    private String sign;

    /**
     * 提现申请应答结果码
     */
    @QuerySqlField(name = "result_code")
    @_AllowUpdate
    private int resultCode;

    /**
     * 提现申请应答的全部文本内容
     */
    @QuerySqlField(name = "response")
    @_AllowUpdate
    private String response;

    /**************以下为异步回调参数字段***************/

    /**
     * 支付确认方式：0——未确认，1——回调通知；2——支付查询
     */
    @QuerySqlField(name = "confirm_mode")
    @_AllowUpdate
    private int confirmMode;

    /**
     * 提现状态: 【3代表审核不通过， 4代表已到账】
     */
    @QuerySqlField(name = "state")
    @_AllowUpdate
    private int state;

    /**
     * 实际提现金额，单位：分。
     */
    @QuerySqlField(name = "actual_amount")
    @_AllowUpdate
    private Long actualAmount;

    /**
     * 接收到回调通知的时间,或定时任务查询提现结果的时间。
     */
    @QuerySqlField(name = "withdraw_time")
    @_AllowUpdate
    private Timestamp withdrawTime;

    /**
     * 是否已同步了钱包余额
     */
    @QuerySqlField(name = "sync_balance")
    @_AllowUpdate
    private Boolean syncBalance;

    @QuerySqlField(name = "create_time")
    private Timestamp createTime;

    @QuerySqlField(name = "version")
    @_AllowUpdate
    private Long version;

    @JsonIgnore
    private boolean insert;

    @Override
    public Long getKey() {
        return id;
    }
}
